﻿using MyAspx.EasyFramework.EntityFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebUI.Form
{
    public partial class CodeFileDisplay : System.Web.UI.Page
    {
        public commyaspxdbEntities _commyaspxdbEntities = new commyaspxdbEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }
        public string fileUrl(string cid)
        {
            
                //var data = _commyaspxdbEntities.my_downurl.Where(p => p.downfileid == cid);
               // if (data.Count() > 0)
            string urls=   "/zipstore/" +Request.QueryString["urldata"];

            return Server.MapPath(urls);
                          // (data.First().downurl.Replace("~", ""));
               // else
                ///    return "";
             
        }
        public string fileData
        {
            get
            {
                using(System.IO.StreamReader sr = new System.IO.StreamReader(fileUrl( Request.QueryString["fid"]),System.Text.Encoding
                    .Default))
                {
                    return sr.ReadToEnd();
                }
                //return "";
            }
        } 
        public string CodeName { get{string fids = Request.QueryString["fid"].ToString();return _commyaspxdbEntities.my_fileinfo.Where(a=>a.fileid==fids).FirstOrDefault().filename;} }
        public string fileName { get; set; }
        public string fileNameFit { get{
        string url = Request.QueryString["urldata"].ToString();
            string[] urls = url.Split('/');
            return urls[urls.Length-1].ToString();
        
        }  }
    }
}